package com.jl.smartcard.ui.views.filesystem;

import java.util.List;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;


class ViewContentProvider implements IStructuredContentProvider,
		ITreeContentProvider {
	/**
		 * 
		 */
	private final CardFileSystemView cardFileSystemView;

	/**
	 * @param cardFileSystemView
	 */
	ViewContentProvider(CardFileSystemView cardFileSystemView) {
		this.cardFileSystemView = cardFileSystemView;
	}

	@Override
	public void inputChanged(Viewer v, Object oldInput, Object newInput) {
	}

	@Override
	public void dispose() {
	}

	@Override
	public Object[] getElements(Object parent) {
		if (parent instanceof List) {
			return ((List<?>) parent).toArray();
		} else if (parent instanceof TreeDF) {
			return ((TreeDF) parent).getChildren();
		}
		return new String[0];
	}

	@Override
	public Object getParent(Object child) {
		if (child instanceof TreeEF) {
			return ((TreeEF) child).getParent();
		}
		return null;
	}

	@Override
	public Object[] getChildren(Object parent) {
		if (parent instanceof TreeDF) {
			return ((TreeDF) parent).getChildren();
		}
		return new Object[0];
	}

	@Override
	public boolean hasChildren(Object parent) {
		if (parent instanceof TreeDF)
			return ((TreeDF) parent).hasChildren();
		return false;
	}
}